package gzx.datalayer.Data.SysMng
{
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	
	public class SysmngQuery
	{
		private var remoteObject:RemoteObject
		private var model:SysmngQueryModel; 
		
		public var onReceive_GetUserInfoList:Function;
		public var onReceive_GetUserBaseInfo:Function;
		public var onReceive_DeleteUserBaseInfo:Function;
		public var onReceive_GetRoleInfoList:Function;
		public var onReceive_DeleteRoleBaseInfo:Function;
		public var onReceive_EditUserInfo:Function;
		public var onReceive_EditRoleInfo:Function;
		public var onReceive_GetMenuList:Function;
		public var onReceive_GetRoleBaseInfo:Function;
		public var onReceive_GetPhoneSysLogInfo:Function;
		public var onReceive_StatisticsPhoneSysLoginInfo:Function;
		
		public var onReceive_GetStatisInfoByFuncName:Function;
		public var onReceive_GetStatisInfoByUserName:Function;
		public var onReceive_GetSysParamInit:Function;
		public var onReceive_SetSysParamInfo:Function;
		public var onReceive_GetSysParamPianQuInfo:Function;
		
		
		public var onErrorFunction:Function;
		
		public function SysmngQuery( model:SysmngQueryModel = null )
		{
			remoteObject  = new RemoteObject("fluorine");
			remoteObject.source = "RemoteFlunorineFx.Sysmng.SysmngQuery";
			
			remoteObject.GetUserBaseInfo.addEventListener("result",GetUserBaseInfo_ResultHandler);
			remoteObject.GetUserInfoList.addEventListener("result",GetUserInfoList_ResultHandler);
			remoteObject.DeleteUserBaseInfo.addEventListener("result",DeleteUserBaseInfo_ResultHandler);
			remoteObject.GetRoleInfoList.addEventListener("result",GetRoleInfoList_ResultHandler);
			remoteObject.DeleteRoleBaseInfo.addEventListener("result",DeleteRoleBaseInfo_ResultHandler);
			remoteObject.EditUserInfo.addEventListener("result",EditUserInfo_ResultHandler);
			remoteObject.EditRoleInfo.addEventListener("result",EditRoleInfo_ResultHandler);
			remoteObject.GetMenuList.addEventListener("result",GetMenuList_ResultHandler);
			remoteObject.GetRoleBaseInfo.addEventListener("result",GetRoleBaseInfo_ResultHandler);
			remoteObject.GetPhoneSysLogInfo.addEventListener("result",GetPhoneSysLogInfo_ResultHandler);
			remoteObject.StatisticsPhoneSysLoginInfo.addEventListener("result",StatisticsPhoneSysLoginInfo_ResultHandler);
			
			remoteObject.GetStatisInfoByUserName.addEventListener("result",GetStatisInfoByUserName_ResultHandler);
			remoteObject.GetStatisInfoByFuncName.addEventListener("result",GetStatisInfoByFuncName_ResultHandler);
			remoteObject.GetSysParamInit.addEventListener("result",GetSysParamInit_ResultHandler);
			remoteObject.SetSysParamInfo.addEventListener("result",SetSysParamInfo_ResultHandler);
			remoteObject.GetSysParamPianQuInfo.addEventListener("result",GetSysParamPianQuInfo_ResultHandler);
			
		
			remoteObject.addEventListener("fault", onFault);
			if( model == null )
				model = new SysmngQueryModel();
			
			this.model = model;
			onReceive_GetUserInfoList = null;
			onReceive_GetUserBaseInfo = null;
			onReceive_DeleteUserBaseInfo = null;
			onReceive_GetRoleInfoList = null;
			onReceive_DeleteRoleBaseInfo = null;
			onReceive_EditUserInfo = null;
			onReceive_EditRoleInfo = null;
			onReceive_GetMenuList = null;
			onReceive_GetRoleBaseInfo = null;
			onReceive_GetPhoneSysLogInfo = null;
			onReceive_StatisticsPhoneSysLoginInfo = null;
			onReceive_GetSysParamInit = null;
			onReceive_SetSysParamInfo = null;
			onReceive_GetSysParamPianQuInfo = null;
			onErrorFunction = null;
		}
		
		//====================
		public function GetUserInfoList(searchType:int,searchContent:String
										,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetUserInfoList(searchType,searchContent);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetUserInfoList_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.GetUserInfoList_Result = returnValue;
			
			if(null != onReceive_GetUserInfoList)
				onReceive_GetUserInfoList();
		}
		
		//====================
		public function GetRoleInfoList(searchContent:String
										,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetRoleInfoList(searchContent);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetRoleInfoList_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.GetRoleInfoList_Result = returnValue;
			
			if(null != onReceive_GetRoleInfoList)
				onReceive_GetRoleInfoList();
		}
		
		//====================
		public function GetUserBaseInfo(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetUserBaseInfo();
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetUserBaseInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.GetUserBaseInfo_Result = returnValue;
			
			if(null != onReceive_GetUserBaseInfo)
				onReceive_GetUserBaseInfo();
		}
		
		//====================
		public function DeleteUserBaseInfo(rst:String,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.DeleteUserBaseInfo(rst);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function DeleteUserBaseInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.DeleteUserBaseInfo_Result = returnValue;
			
			if(null != onReceive_DeleteUserBaseInfo)
				onReceive_DeleteUserBaseInfo();
		}
		
		//====================
		public function DeleteRoleBaseInfo(role_id:int,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.DeleteRoleBaseInfo(role_id);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function DeleteRoleBaseInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.DeleteRoleBaseInfo_Result = returnValue;
			
			if(null != onReceive_DeleteRoleBaseInfo)
				onReceive_DeleteRoleBaseInfo();
		}
		
		//====================
		public function EditUserInfo(userInfoItem:UserInfoItem,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.EditUserInfo(userInfoItem);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function EditUserInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.EditUserInfo_Result = returnValue;
			
			if(null != onReceive_EditUserInfo)
				onReceive_EditUserInfo();
		}
		
		//====================
		public function EditRoleInfo(roleInfoItem:RoleInfoItem,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.EditRoleInfo(roleInfoItem);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function EditRoleInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.EditRoleInfo_Result = returnValue;
			
			if(null != onReceive_EditRoleInfo)
				onReceive_EditRoleInfo();
		}
		
		//====================
		public function GetMenuList(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetMenuList();
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetMenuList_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.GetMenuList_Result = returnValue;
			
			if(null != onReceive_GetMenuList)
				onReceive_GetMenuList();
		}
		
		//====================
		public function GetRoleBaseInfo(role_id:int,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetRoleBaseInfo(role_id);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetRoleBaseInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.GetRoleBaseInfo_Result = returnValue;
			
			if(null != onReceive_GetRoleBaseInfo)
				onReceive_GetRoleBaseInfo();
		}
		
		//====================
		public function GetPhoneSysLogInfo(beginTime:String,endTime:String,currentpage:int,pageSize:int,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetPhoneSysLogInfo(beginTime,endTime,currentpage,pageSize);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetPhoneSysLogInfo_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetPhoneSysLogInfo)
				onReceive_GetPhoneSysLogInfo(event.result);
		}
		
		//====================
		public function StatisticsPhoneSysLoginInfo(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.StatisticsPhoneSysLoginInfo();
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function StatisticsPhoneSysLoginInfo_ResultHandler(event:ResultEvent):void
		{
			var returnValue:Object = event.result as Object;
			model.StatisticsPhoneSysLoginInfo_Result = returnValue;
			
			if(null != onReceive_StatisticsPhoneSysLoginInfo)
				onReceive_StatisticsPhoneSysLoginInfo();
		}
		public function GetStatisInfoByUserName(loginCode:String,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetStatisInfoByUserName(loginCode);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
	
		public function GetStatisInfoByUserName_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetStatisInfoByUserName)
				onReceive_GetStatisInfoByUserName(event.result);

		}
		public function GetStatisInfoByFuncName(funcName:String,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetStatisInfoByFuncName(funcName);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetStatisInfoByFuncName_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetStatisInfoByFuncName)
				onReceive_GetStatisInfoByFuncName(event.result);
		}
		
		//====================
		public function GetSysParamInit(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetSysParamInit();
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetSysParamInit_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetSysParamInit)
				onReceive_GetSysParamInit(event.result);
		}
		
		//====================
		public function SetSysParamInfo(setParamItem:SetParamItem,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.SetSysParamInfo(setParamItem);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function SetSysParamInfo_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_SetSysParamInfo)
				onReceive_SetSysParamInfo(event.result);
		}
		
		//====================
		public function GetSysParamPianQuInfo(userId:String,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetSysParamPianQuInfo(userId);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetSysParamPianQuInfo_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetSysParamPianQuInfo)
				onReceive_GetSysParamPianQuInfo(event.result);
		}

		//=========================
		public function onFault (event:FaultEvent):void
		{
			if(onErrorFunction!=null)
			{
				onErrorFunction();
			}
			else
			{
				Alert.show(event.fault.faultString, "Error");
			}
		}
	}
}